package com.wzh.glsc.order.web;

import com.wzh.glsc.order.service.OrderItemService;
import com.wzh.glsc.order.vo.OrderConfirmVo;
import com.wzh.glsc.order.vo.OrderSubmitVo;
import com.wzh.glsc.order.vo.SubmitOrderResponseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.concurrent.ExecutionException;

/**
 * @author xiaoming
 * @PackageName:com.wzh.glsc.order.web
 * @ClassName:@{NAME}
 * @Description:
 * @date:@{DATE}@{TIME}
 */
@Controller
public class webController {

//    @Autowired
//    ThreadPoolExecutor threadPoolExecutor;
    @Autowired
    OrderItemService orderItemService;

    @GetMapping("detail")
    public String detail() {

        return "detail";
    }

    @GetMapping("list")
    public String list() {

        return "list";
    }

    @GetMapping("confirm")
    public String confirm(Model model) throws ExecutionException, InterruptedException {
        OrderConfirmVo orderConfirmVo=orderItemService.queryOrderCofirm();
        model.addAttribute("confirmOrder", orderConfirmVo);
        return "confirm";
    }

    @RequestMapping("submitOrder")
    public String submitOrder(OrderSubmitVo orderSubmitVo) {
        System.out.println("1");
        SubmitOrderResponseVo responseVo=orderItemService.submitOrder(orderSubmitVo);
        if(responseVo.getCode()==1){
            return "redirect:http://order.gulimall.html/confirm";
        }

        return "pay";
    }

//
//    @GetMapping("pay")
//    public String pay() {
//
//        return "pay";
//    }

}
